home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / LinConst.h < prev    next >
C/C++ Source or Header  |  1996-03-03  |  2KB  |  100 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_LinConst_h)
  24. #define octave_LinConst_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. class ostream;
  31.  
  32. class ColumnVector;
  33.  
  34. #include <cfloat>
  35.  
  36. #include "dMatrix.h"
  37. #include "Bounds.h"
  38.  
  39. class
  40. LinConst : public Bounds
  41. {
  42. public:
  43.  
  44.   LinConst (void)
  45.     : Bounds (), A () { }
  46.  
  47.   LinConst (const ColumnVector& l, const Matrix& amat, const ColumnVector& u)
  48.     : Bounds (l, u), A (amat)
  49.       {
  50.     if (Bounds::size () != amat.rows ())
  51.       error ("nonconformant constraint matrix and bounds vectors");
  52.       }
  53.  
  54.   LinConst (const LinConst& a)
  55.     : Bounds (a.lb, a.ub), A (a.A) { }
  56.  
  57.   LinConst& operator = (const LinConst& a)
  58.     {
  59.       if (this != &a)
  60.     {
  61.       Bounds::operator = (a);
  62.  
  63.       A  = a.A;
  64.     }
  65.       return *this;
  66.     }
  67.  
  68.   ~LinConst (void) { }
  69.  
  70.   Matrix constraint_matrix (void) const { return A; }
  71.  
  72.   LinConst& set_constraint_matrix (const Matrix& amat)
  73.     {
  74.       if (lb.capacity () != amat.rows ())
  75.     error ("inconsistent size for new linear constraint matrix");
  76.  
  77.       A = amat;
  78.  
  79.       return *this;
  80.     }
  81.  
  82.   friend ostream& operator << (ostream& os, const LinConst& b);
  83.  
  84. protected:
  85.  
  86.   Matrix A;
  87.  
  88. private:
  89.  
  90.   void error (const char *msg);
  91. };
  92.  
  93. #endif
  94.  
  95. /*
  96. ;;; Local Variables: ***
  97. ;;; mode: C++ ***
  98. ;;; End: ***
  99. */
  100.